//by shawn.tan
`ifndef C_BFM_TASK_SVH
`define C_BFM_TASK_SVH
task wait_us(input int uint);
    repeat(uint) #1us;
endtask : wait_us

task wait_ms(input int uint);
    repeat(uint) #1ms;
endtask : wait_ms

task TestStart();
    ezchip_base_test top;
    top = ezchip_base_test::m_obj;
    //top.test_start.wait_trigger();
    $display("START C DPI TEST");
endtask : TestStart

task TestEnd();
    ezchip_base_test top;
    top = ezchip_base_test::m_obj;
    top.test_end.trigger();
    $display("END C DPI TEST");
endtask : TestEnd

task reg_write(input int unsigned addr, int unsigned data);
    ezchip_base_test top;
    top = ezchip_base_test::m_obj;
    `uvm_info("C-DPI", $sformatf("Addr:%08x Write Data:0x%08x", addr, data), UVM_HIGH)
    top.wr_seq.start_addr = addr;
    top.wr_seq.write_data = data;
    top.wr_seq.start(top.ahb_agt.hacc_reg_sqr);
endtask : reg_write

task reg_read(input int unsigned addr, output int unsigned data);
    ezchip_base_test top;
    top = ezchip_base_test::m_obj;
    top.rd_seq.start_addr = addr;
    top.rd_seq.start(top.ahb_agt.hacc_reg_sqr);
    data=top.rd_seq.rsp.data;
    `uvm_info("C-DPI", $sformatf("Addr:%08x Read Data:0x%08x", addr, data), UVM_HIGH)
endtask : reg_read
`endif
